package com.js.mvpdemo.adapter;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.js.lib_common.mvp.model.response.MissionResponse;
import com.js.mvpdemo.BaseApplication;
import com.js.mvpdemo.R;
import com.shuhart.stepview.StepView;

import java.util.List;

/**
 * 任务列表adapter
 * Created by wz on 2020/11/9.
 */
public class MissionListAdapter extends BaseQuickAdapter<MissionResponse, BaseViewHolder> {

    public MissionListAdapter(List<MissionResponse> data) {
        super(R.layout.item_mission_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MissionResponse bean) {
        helper.setText(R.id.tv_distributeTimeStr, bean.getDistributeTimeStr());
        helper.setText(R.id.tv_taskName, bean.getTaskName());
        helper.setText(R.id.tv_address, bean.getRtuName());
        helper.setText(R.id.tv_hourTotal, bean.getHourTotal());
        helper.setText(R.id.tv_logInfo, bean.getLogInfo());

        switch (bean.getOrderType()) {
            case 1:
                helper.setBackgroundRes(R.id.img_orderType, R.mipmap.ic_tab_list_sg);
                helper.setText(R.id.tv_taskName, "钢管施工-" + bean.getTaskName());
                break;
            case 2:
                helper.setBackgroundRes(R.id.img_orderType, R.mipmap.ic_tab_list_sg);
                helper.setText(R.id.tv_taskName, "PE管施工-" + bean.getTaskName());
                break;
            case 3:
                helper.setBackgroundRes(R.id.img_orderType, R.mipmap.ic_tab_list_gf);
                helper.setText(R.id.tv_taskName, "关阀-" + bean.getTaskName());
                break;
            case 4:
                helper.setBackgroundRes(R.id.img_orderType, R.mipmap.ic_tab_list_jy);
                helper.setText(R.id.tv_taskName, "降压-" + bean.getTaskName());
                break;
        }

        StepView mStepsView = helper.getView(R.id.step_view);
        mStepsView.getState()
                .selectedTextColor(ContextCompat.getColor(BaseApplication.getInstance(), R.color.colorAccent))
                .animationType(StepView.ANIMATION_CIRCLE)
                .selectedCircleColor(ContextCompat.getColor(BaseApplication.getInstance(), R.color.colorAccent))
                //                .selectedCircleRadius(getResources().getDimensionPixelSize(R.dimen.dp14))
                .selectedStepNumberColor(ContextCompat.getColor(BaseApplication.getInstance(), R.color.colorPrimary))
                //                .steps(list)
                .stepsNumber( bean.getTotalStep())
                .animationDuration(BaseApplication.getInstance().getResources().getInteger(android.R.integer.config_shortAnimTime))
                .commit();
        mStepsView.done(true);
        mStepsView.go( bean.getCurrentStep()-1, true);
    }


}
